<?php

use Biz\service\designerAward\Main as sMain;
/**
 * @deprecated
 */
class AddUserAction extends ActionPlugin
{
    const USER_LEVEL = self::LEVEL_REALNAME;

    public function main()
    {
        $uid = $this->uid;

        $request = $this->getRequest()->getPost();
        if(!empty($request)){
            foreach($request as $_k=>&$_v){
                $data[$_k] = $_v;
            }
        }

        $data['uid'] = $uid;

        if(empty($data['uid']) && empty($data['types'])){
            throw new \Exception('用户或类别不存在');
        }else{
            if ($save = sMain::addUser($data)) {
                if(isset($save['error'])) {
                    throw new \Exception($save['error']);
                }else{
                    $result = $save;
                    $this->setSuccess($result);
                }
            } else {
                throw new \Exception('保存失败，请稍后重试');
            }
        }
    }
}